package com.jic.member.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberIntegralAction;
import com.jic.member.mapper.MememberIntegralActionMapper;
import com.jic.member.service.MememberIntegralActionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评价-分享-点赞-晒单-收藏赠送表
 * @author : 
 * @email : 
 * @since : 2020-04-02 03:06:16
 * @version : v1.0.0
 */
@Service
public class MememberIntegralActionServiceImpl implements MememberIntegralActionService {

    @Autowired
    private MememberIntegralActionMapper mememberIntegralActionMapper;

    @Override
    public long insert(MememberIntegralAction mememberIntegralAction) {
        long flag = mememberIntegralActionMapper.insert(mememberIntegralAction);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberIntegralActionMapper.delete(id);
    }

    @Override
    public long update(MememberIntegralAction mememberIntegralAction) {
        return mememberIntegralActionMapper.update(mememberIntegralAction);
    }

    @Override
    public MememberIntegralAction queryByPrimaryKey(Long id){
        return mememberIntegralActionMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberIntegralAction> query(MememberIntegralAction mememberIntegralAction){
        return mememberIntegralActionMapper.query(mememberIntegralAction);
    }

    @Override
    public PageResult<MememberIntegralAction> queryPage(MememberIntegralAction mememberIntegralAction, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberIntegralAction> list = mememberIntegralActionMapper.queryPage(startIndex, pageQuery.getLimit(), mememberIntegralAction);
        long count = mememberIntegralActionMapper.queryPageCount(mememberIntegralAction);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}